package com.servlet.web;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Title: ResponseServlet05
 * @Description:
 * @Auther: py
 * @Version: 1.0
 * @create 2023/12/22 10:28
 */
@WebServlet("/resp05")
public class ResponseServlet05 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // 设置重定向的状态码 302
//           resp.setStatus(302);
//           // 设置响应的网址
//           resp.setHeader("Location","https://www.baidu.com/");
        // 重定向跳转到新的页面
        resp.sendRedirect("https://www.baidu.com/");


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }

}
